jQuery(document).ready(function($){$.getJSON(window.location.href,{action:"load_alerts"},function(response){if(response.items.length){console.log(response.items.length+" alerts found.");var $container=$("
"),current_item_index=null,current_item=null,openingTimeout=null,closingTimeout=null,first_showing=!0;$container.addClass("proof-design-"+response.settings.design_type),$container.addClass("proof-position-"+response.settings.position),response.settings.clickable&&$container.addClass("proof-clickable"),response.settings.show_time_ago&&$container.addClass("proof-show-timeago"),response.settings.show_on_desktop&&$container.addClass("proof-desktop"),response.settings.show_on_mobile&&$container.addClass("proof-mobile"),response.settings.show_close_button&&$container.append("
"),$container.appendTo("body");function showNextProof(){if(first_showing?current_item_index=0:current_item_index++,current_item_index>response.items.length-1){if(!response.settings.loop)return;current_item_index=0}current_item=response.items[current_item_index],$("").attr("src",current_item.image),clearTimeout(openingTimeout),clearTimeout(closingTimeout),openingTimeout=setTimeout(function(){if(current_item.image?$("#proof-image").empty().css("background-image","url("+current_item.image+")"):$("").addClass(current_item.icon).css({background:current_item.icon_background_color,color:current_item.icon_color}).appendTo($("#proof-image").empty().css("background-image","none")),$("#proof-title").html(current_item.title).attr("title",current_item.title),$("#proof-text").html(current_item.content).attr("title",current_item.content),response.settings.show_time_ago&&$("#proof-time").html(current_item.time),current_item.visitors_count){$("#proof-title").remove(),$("#proof-time").remove(),$("#proof-text").replaceWith('
'+current_item.content+"
");var noVisitors=parseInt(current_item.noVisitors),count=new window.CountUp("visitors-count",0,noVisitors,0,5,{useEasing:!0,useGrouping:!0,separator:",",decimal:"."});count.error?console.error(count.error):count.start()}1==response.settings.wc_verified&&$("#proof-wc-verified").html('').append(op_urgency_tr.wp_verified),1==response.settings.optimizecheckouts_verified&&$("#proof-optimizecheckouts-verified").html('').append(op_urgency_tr.optimizecheckouts_verified),1==response.settings.optimizepress_verified&&$("#proof-optimizepress-verified").html('').append(op_urgency_tr.optimizepress_verified),$("#proof").removeClass("proof-hidden").addClass("proof-displayed"),closingTimeout=setTimeout(function(){closeProof()},1e3*response.settings.duration)},1e3*(first_showing?response.settings.delay:response.settings.interval)),first_showing=first_showing&&!1}var closeProof=function(){$("#proof").removeClass("proof-displayed"),$("#proof").addClass("proof-hidden"),showNextProof()};$("#proof-close").on("click",function(e){e.stopPropagation(),closeProof()}),$container.on("click",function(e){current_item.link&&window.open(current_item.link)}),showNextProof()}else console.log("No alerts found.")})});